<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <script>

        // let obj = {};

        // obj.a = 12;

        // obj["b"] = 5;

        // console.log(obj);


        let name = "username";
        let num = 100;

        // 用[]传入对应的变量或者表达式，去定义属性名。
        let obj = {
            a:12,
            [name]:"老王",
            ["a"+num]:"王者"
        }

        console.log(obj); //{a: 12, username: '老王'}





    </script>
</body>
</html>